Xbasic

SQL::StatementValidate Method

Syntax

Result_Flag as L = Validate([SQLConnection as SQL::Connection | SQLConnectionString as C] [UpdateStatistics as L])

Arguments

Result_Flag

TRUE (.T.) if the operation was successful; otherwise FALSE (.F.).

SQLConnection

Optional. A SQL::Connection object created with a DIM statement with a defined .ConnectionString property.

SQLConnectionString

Optional. A connection string.

Description

Execute the current statement using the current or passed connection.

Discussion

The .Validate() method prepares the query and validates it, but does not execute it. (In some implementations the query is executed with a limit on rows set to 1). The intent is to force the query through a server side parse and report problems. The method connects to the back-end database using the information in the SQL::Connection::ConnectionString property or in the ConnectString string, then executes the current SQL statement stored in the SQL::Statement.SQLStatement property. Note: Not every database is thorough about validation.

Example

dim conn as SQL::Connection
dim connString as C
dim stat as SQL::Statement
dim sql_insert as C
connString = "{A5API='Access', FileName='c:\program files\a5v7\mdbfiles\alphasports.mdb'}"
sql_insert = "insert into customer (firstname, lastname, bill_city, bill_postal_code,bill_state_region) values ('George', 'Jones', 'Arlington', '02000', 'VA')"
? conn.open(connString)
= .T.
? stat.parse(sql_insert)
= .T.
? stat.validate(conn)
= .T.

See Also